// ESM version of the start script
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const apps = [
  { name: 'main', port: 8000 },
  { name: 'app1', port: 8001 },
  { name: 'app2', port: 8002 },
  { name: 'app3', port: 8003 }
];

apps.forEach(({ name, port }) => {
  const appPath = join(__dirname, `../${name === 'main' ? '.' : name}`);
  spawn('npm', ['run', 'dev'], {
    cwd: appPath,
    stdio: 'inherit',
    shell: true
  });
});